import requests

headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Connection": "keep-alive",
    "Content-Length": "0",
    "Origin": "https://ec.minmetals.com.cn",
    "Referer": "https://ec.minmetals.com.cn/open/home/platform-info",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0",
    "sec-ch-ua": "\"Chromium\";v=\"142\", \"Microsoft Edge\";v=\"142\", \"Not_A Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\""
}
cookies = {
    "SUNWAY-ESCM-COOKIE": "f74e9527-1c93-408c-909b-10778b9d5265",
    "__jsluid_s": "1145fa590c5739936bfcf3abcd4ec097",
    "JSESSIONID": "F667D67BAE296763D3A85B55934C6E7B"
}
url = "https://ec.minmetals.com.cn/open/homepage/public"
public_key = requests.post(url, headers=headers, cookies=cookies)
print(public_key.text)
url = "https://ec.minmetals.com.cn/open/homepage/tzggs/by-bz-page"

import execjs
import json
with open("20.js", "r", encoding="utf-8") as f:
    js_code = f.read()

cpl = execjs.compile(js_code)
request_param = cpl.call('get_requestStr', 1, public_key.text)

data = {
    "param": request_param
}
headers['Content-Type'] = 'application/json'
data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, cookies=cookies, data=data)

print(response.text)
print(response)
